﻿using Microsoft.EntityFrameworkCore;
using System;
using System.Collections.Generic;
using System.Text;
using Volo.Abp.AuditLogging.EntityFrameworkCore;
using Volo.Abp.Data;
using Volo.Abp.EntityFrameworkCore;
using Volo.Abp.Identity.EntityFrameworkCore;
using Volo.Abp.IdentityServer.ApiResources;
using Volo.Abp.IdentityServer.Clients;
using Volo.Abp.IdentityServer.EntityFrameworkCore;
using Volo.Abp.PermissionManagement.EntityFrameworkCore;
using Volo.Abp.SettingManagement.EntityFrameworkCore;
using Volo.Abp.TenantManagement.EntityFrameworkCore;

namespace OnePay.DbMigrations.EntityFrameworkCore.AbpDb.EntityFrameworkCore
{
    [ConnectionStringName("AbpIdentity")]
    public class AbpMigrationsDbContext : AbpDbContext<AbpMigrationsDbContext>
    {
        public AbpMigrationsDbContext(DbContextOptions<AbpMigrationsDbContext> options)
            : base(options)
        {
        }

        protected override void OnModelCreating(ModelBuilder builder)
        {
            base.OnModelCreating(builder);

            builder.ConfigureIdentity();
            builder.ConfigureIdentityServer();
            builder.ConfigurePermissionManagement();
            builder.ConfigureAuditLogging();
            builder.ConfigureSettingManagement();
            builder.ConfigureTenantManagement();

            builder.Entity<ApiSecret>(b => {
                b.Property(x => x.Value).HasMaxLength(400);
            });

            builder.Entity<ClientPostLogoutRedirectUri>(b => {
                b.Property(x => x.PostLogoutRedirectUri).HasMaxLength(400);
            });

            builder.Entity<ClientRedirectUri>(b => {
                b.Property(x => x.RedirectUri).HasMaxLength(400);
            });

            builder.Entity<ClientSecret>(b => {
                b.Property(x => x.Value).HasMaxLength(400);
            });
        }
    }
}
